<template>
  <div>
    <!-- 头部导航栏 -->
    <van-nav-bar
      title="收货地址"
      left-arrow
      @click-left="onClickLeft"
      fixed
      placeholder
      z-index="999"
    >
    </van-nav-bar>

    <!-- 地址信息 -->
    <van-cell-group>
      <van-cell title="收货人" :value="userInfo.userName" />
      <van-cell title="手机号" :value="userInfo.userPhone" />
      <van-cell title="列车次号" :value="userInfo.address.trainName" />
      <van-cell title="车厢号" :value="userInfo.address.trainNum" />
      <van-cell title="座位号" :value="userInfo.address.seatNum" />
    </van-cell-group>

    <!-- 底部修改按钮 -->
    <div class="btns_edit">
        <van-button type="info" round @click="toEditAddress">修改地址</van-button>
    </div>
    
  </div>
</template>
<script>
export default {
  data() {
    return {
      userInfo: {}
    };
  },
  created() {
    //加载用户信息
    let userInfo = JSON.parse(window.localStorage.getItem('user'))
    this.userInfo = userInfo
  },
  methods: {
    //点击左上角返回键
    onClickLeft() {
      this.$router.go(-1);
    },
    //修改收货地址
    toEditAddress() {
        this.$router.push('/address/edit')
    }
  }
};
</script>
<style lang="less" scoped>
.btns_edit {
    position: fixed;
    width: 100%;
    bottom: 0;
    left: 0;
    justify-content: center;
    .van-button {
        width: 100%;
    }
}
</style>
